<template>
  <div>
    <div class="head">
      <span>计划生成</span>
      <button @click="send">数据入库</button>
      <button>退出</button>
    </div>
    <div class="container">
      <div class="item">
        <span>院系名称：</span>
        <el-select v-model="yxmc" filterable placeholder="请选择">
          <el-option
            v-for="item in yxmcs"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </div>
      <div class="item">
        <span>专业名称：</span>
        <el-input v-model="zymc" placeholder="请输入内容"></el-input>
      </div>
      <div class="item">
        <span>省份名称：</span>
        <el-select v-model="sfmc" filterable placeholder="请选择">
          <el-option
            v-for="item in sfmcs"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </div>
      <div class="item">
        <span>计划类别：</span>
        <el-select v-model="jhlbmc" filterable placeholder="请选择">
          <el-option
            v-for="item in jhlbmcs"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </div>
      <div class="item">
        <span>学习年限：</span>
        <el-input v-model="xz" placeholder="请输入内容"></el-input>
      </div>
      <div class="item">
        <span>所属科类：</span>
        <el-select v-model="kl" filterable placeholder="请选择">
          <el-option
            v-for="item in kls"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </div>
      <div class="item">
        <span>招生人数：</span>
        <el-input v-model="zsrs" placeholder="请输入内容"></el-input>
      </div>
      <div class="item">
        <span>备注信息：</span>
        <el-input v-model="bz" placeholder="请输入内容"></el-input>
      </div>
    </div>
  </div>
</template>

<script>
import { request } from "../../network/request";
export default {
  name: "",
  data() {
    return {
      yxmcs: [
        {
          value: "土木工程学院",
          label: "土木工程学院",
        },
        {
          value: "建筑学院",
          label: "建筑学院",
        },
        {
          value: "环境科学与工程学院",
          label: "环境科学与工程学院",
        },
        {
          value: "机械与运载工程学院",
          label: "机械与运载工程学院",
        },
        {
          value: "设计艺术学院",
          label: "设计艺术学院",
        },
        {
          value: "工商管理学院",
          label: "工商管理学院",
        },
        {
          value: "电气与信息工程学院",
          label: "电气与信息工程学院",
        },
        {
          value: "信息科与工程学院",
          label: "信息科与工程学院",
        },
        {
          value: "国家保密学院",
          label: "国家保密学院",
        },
        {
          value: "化学化工学院",
          label: "化学化工学院",
        },
        {
          value: "数学与计量经济学院",
          label: "数学与计量经济学院",
        },
        {
          value: "物理与微电子科学学院",
          label: "物理与微电子科学学院",
        },
      ],
      yxmc: "",
      sfmcs: [
        {
          value: "北京",
          label: "北京",
        },
        {
          value: "天津",
          label: "天津",
        },
        {
          value: "上海",
          label: "上海",
        },
        {
          value: "重庆",
          label: "重庆",
        },
        {
          value: "河北",
          label: "河北",
        },
        {
          value: "山西",
          label: "山西",
        },
        {
          value: "辽宁",
          label: "辽宁",
        },
        {
          value: "吉林",
          label: "吉林",
        },
        {
          value: "黑龙江",
          label: "黑龙江",
        },
        {
          value: "江苏",
          label: "江苏",
        },
        {
          value: "浙江",
          label: "浙江",
        },
        {
          value: "安徽",
          label: "安徽",
        },
        {
          value: "福建",
          label: "福建",
        },
        {
          value: "江西",
          label: "江西",
        },
        {
          value: "山东",
          label: "山东",
        },
        {
          value: "河南",
          label: "河南",
        },
        {
          value: "湖北",
          label: "湖北",
        },
        {
          value: "湖南",
          label: "湖南",
        },
        {
          value: "广东",
          label: "广东",
        },
        {
          value: "海南",
          label: "海南",
        },
        {
          value: "四川",
          label: "四川",
        },
        {
          value: "贵州",
          label: "贵州",
        },
        {
          value: "云南",
          label: "云南",
        },
        {
          value: "陕西",
          label: "陕西",
        },
        {
          value: "甘肃",
          label: "甘肃",
        },
        {
          value: "青海",
          label: "青海",
        },
        {
          value: "台湾",
          label: "台湾",
        },
        {
          value: "内蒙古",
          label: "内蒙古",
        },
        {
          value: "广西",
          label: "广西",
        },
        {
          value: "西藏",
          label: "西藏",
        },
        {
          value: "宁夏",
          label: "宁夏",
        },
        {
          value: "新疆",
          label: "新疆",
        },
        {
          value: "香港",
          label: "香港",
        },
        {
          value: "澳门",
          label: "澳门",
        },
      ],
      sfmc: "",
      jhlbmcs: [
        {
          value: "理工",
          label: "理工",
        },
        {
          value: "文史",
          label: "文史",
        },
        {
          value: "综合",
          label: "综合",
        },
        {
          value: "艺术",
          label: "艺术",
        },
      ],
      jhlbmc: "",
      kls: [
        {
          value: "普通",
          label: "普通",
        },
        {
          value: "国家专项",
          label: "国家专项",
        },
        {
          value: "高校专项",
          label: "高校专项",
        },
      ],
      kl: "",
      zymc: "",
      xz: "",
      zsrs: "",
      bz: "",
    };
  },
  methods: {
    send() {
      if (
        this.yxmc == "" ||
        this.zymc == "" ||
        this.sfmc == "" ||
        this.jhlbmc == "" ||
        this.xz == "" ||
        this.kl == "" ||
        this.zsrs == ""
      ) {
        alert("除备注外均需填写");
      } else {
        request({
          url: "http://118.31.51.131:8081/api/zsjh/dr",
          method: "post",
          data: {
            yxmc: this.yxmc,
            zymc: this.zymc,
            sfmc: this.sfmc,
            jhlbmc: this.jhlbmc,
            xz: this.xz,
            klmc: this.kl,
            zsrs: this.zsrs,
            bz: this.bz,
          },
          params: {
            token: sessionStorage.getItem("token"),
          },
        })
          .then((value) => {
            console.log(value);
            alert("入库成功");
          })
          .catch((err) => {
            console.log(err);
            alert("入库失败");
          });
      }
    },
  },
  beforeCreate() {
    if (sessionStorage.getItem("token") == null) {
      this.$router.push("/login");
    } else {
      let token = sessionStorage.getItem("token");
      let length = sessionStorage.getItem("token").length;
      if (token[length - 5] == "0") {
        this.$router.replace("/login");
      }
    }
  },
  components: {},
};
</script>

<style scoped>
.head {
  height: 80px;
  border-bottom: 1px solid black;
}
.head span {
  font-size: 20px;
  line-height: 80px;
  margin-left: 25px;
}
.head button:nth-of-type(1) {
  margin-left: 1120px; 
}
.head button:nth-of-type(2) {
  margin-left: 100px;
}
button {
  width: 100px;
  height: 50px;
  border: none;
  outline: none;
  cursor: pointer;
  color: #fff;
  background-color: rgb(192, 51, 56);
}
button:active {
  opacity: 0.8;
}
.el-input {
  width: 200px;
}
.container {
  display: flex;
  flex-wrap: wrap;
  margin-top: 80px;
}
.item {
  width: 50%;
  height: 120px;
  text-align: center;
}
</style>